package net.lucamasini.ricette.rest.impl;

import java.util.List;

import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;

import net.lucamasini.ricette.model.Ingrediente;
import net.lucamasini.ricette.model.Ricetta;
import net.lucamasini.ricette.model.TipoIngrediente;
import net.lucamasini.ricette.server.RicetteServiceServlet;

@Path("/entities/")
public class RicetteResource {

	@GET
	@Produces("application/xml")
	@Path("/ricette/all")
	public List<Ricetta> getRicette(final @Context ServletContext context) {
		final RicetteServiceServlet service = new RicetteServiceServlet(){
			private static final long serialVersionUID = 1L;

			@Override
			public ServletContext getServletContext() {
				return context;
			}
		};
		
		return service.findAllRicette();
	}

	@GET
	@Produces("application/xml")
	@Path("/ingredienti/all")
	public List<Ingrediente> getIngredienti(final @Context ServletContext context) {
		final RicetteServiceServlet service = new RicetteServiceServlet(){
			private static final long serialVersionUID = 1L;

			@Override
			public ServletContext getServletContext() {
				return context;
			}
		};
		
		return service.findAllIngredienti();
	}

	@GET
	@Produces("application/xml")
	@Path("/tipoingredienti/all")
	public List<TipoIngrediente> getTipoIngredienti(final @Context ServletContext context) {
		final RicetteServiceServlet service = new RicetteServiceServlet(){
			private static final long serialVersionUID = 1L;

			@Override
			public ServletContext getServletContext() {
				return context;
			}
		};
		
		return service.findAllTipoIngredienti();
	}
}
